#!/bin/bash

# daily.local: Local items appended to the daily periodic scripts.

MAX_SLEEP=3600
IHOOK_LAUNCHAGENT="edu.umich.iHook.radmind"

# Source Radmind defaults
. /private/etc/radmind.defaults

# Touch the "Radmind with Checksums" flag since we're running the daily script.
/usr/bin/touch "${CHECKSUM_FLAG}"

# Sleep for a random amount of time (<= MAX_SLEEP) to avoid hitting the Radmind
# server all at once.

sleepTime=$RANDOM
let "sleepTime %= $MAX_SLEEP"

/bin/sleep ${sleepTime}

# Touch the flag, which will either start Radmind instantly (if no-one is logged
# in) or schedule it for logout.

/usr/bin/touch "${RADMIND_FLAG}"
